﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Client
{
    public partial class AttendenceCheck : Form
    {
        #region -  EVENTS  -
        public event AttendenceCheckEventHandler OnAttendenceCheck = null;
        public event FormExitEventHandler OnFormExit = null;
        #endregion

        #region -  CONTRUCTOR  -
        public AttendenceCheck()
        {
            InitializeComponent();
        }
        #endregion

        #region -  APPLY  -
        private void btnApply_Click(object sender, EventArgs e)
        {
            if (this.tbxMSSV.Text != null && this.tbxName.Text != null)
            {
                if (this.OnAttendenceCheck != null)
                {
                    this.OnAttendenceCheck(this, new AttendenceCheckEventArgs(this.tbxMSSV.Text,
                        this.tbxName.Text));
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Chưa nhập đủ dữ liệu.", "Thông báo",
                     MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        #endregion

        #region - KEY DOWN  -
        private void tbxMSSV_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.D0 ||
                e.KeyCode == Keys.D1 ||
                e.KeyCode == Keys.D2 ||
                e.KeyCode == Keys.D3 ||
                e.KeyCode == Keys.D4 ||
                e.KeyCode == Keys.D5 ||
                e.KeyCode == Keys.D6 ||
                e.KeyCode == Keys.D7 ||
                e.KeyCode == Keys.D8 ||
                e.KeyCode == Keys.D9 ||
                e.KeyCode == Keys.NumPad0 ||
                e.KeyCode == Keys.NumPad1 ||
                e.KeyCode == Keys.NumPad2 ||
                e.KeyCode == Keys.NumPad3 ||
                e.KeyCode == Keys.NumPad4 ||
                e.KeyCode == Keys.NumPad5 ||
                e.KeyCode == Keys.NumPad6 ||
                e.KeyCode == Keys.NumPad7 ||
                e.KeyCode == Keys.NumPad8 ||
                e.KeyCode == Keys.Back)
            { }
            else
            {
                MessageBox.Show("Chỉ được gõ số vào ô này.", "Thông báo",
                     MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        #endregion

        #region -  FORM CLOSED  -
        private void AttendenceCheck_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (this.OnFormExit != null)
            {
                this.OnFormExit(this, new FormExitEvenArgs());
            }
        }
        #endregion

        #region -  FORM LOAD  -
        private void AttendenceCheck_Load(object sender, EventArgs e)
        {
        }
        #endregion
    }
}
